package com.chuanyang.driverh.mainmy;


import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chuanyang.driverh.BaseApplication;
import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseTitleActivity;
import com.chuanyang.driverh.responseresult.DriverInfoData;
import com.chuanyang.driverh.utils.ActivityUtil;
import com.chuanyang.driverh.utils.eventbus.ExitAppEvent;

import de.greenrobot.event.EventBus;

public class AccountSecureActivity extends BaseTitleActivity {

    private DriverInfoData driverinfo;
    private TextView tv_accountsecure_phone;
    private RelativeLayout rl_accountsecure_changeaccount;
    private RelativeLayout rl_accountsecure_changepassword;

    @Override
    protected int getContentResId() {
        return R.layout.my_act_accountsecure;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
         rl_accountsecure_changepassword = (RelativeLayout) findViewById(R.id.rl_accountsecure_changepassword);
        rl_accountsecure_changeaccount = (RelativeLayout) findViewById(R.id.rl_accountsecure_changeaccount);
        tv_accountsecure_phone= (TextView) findViewById(R.id.tv_accountsecure_phone);
    }


    @Override
    public void initData() {
        driverinfo = BaseApplication.getInstance().getDriverInfo();
        setBackImg();
        getTitleTextView().setText("账户与安全");
        if(!TextUtils.isEmpty(driverinfo.getPhone()))
        {
            tv_accountsecure_phone.setText(driverinfo.getPhone());
        }else {
            tv_accountsecure_phone.setText("---");
        }
    }

    @Override
    protected void initListener() {
        rl_accountsecure_changepassword.setOnClickListener(this);
        rl_accountsecure_changeaccount.setOnClickListener(this);
        tv_accountsecure_phone.setOnClickListener(this);

    }
    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.rl_accountsecure_changepassword:
                ActivityUtil.startActivity(activityContext,ChangePasswordActivity.class);
                break;
            case R.id.rl_accountsecure_changeaccount:
//                ActivityUtil.startActivity(activityContext, LoginActivity.class);
                EventBus.getDefault().post(new ExitAppEvent(true,true));
                break;
        }
    }
}
